package com.boot.web;

import com.boot.model.UserDto;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author Chunsheng.Zhang
 * @date 2021/4/8 11:13
 * @description : TODO
 */
@RestController
@RequestMapping("/user")
public class UserController {



    @RequestMapping("/m1")
    public String m1(HttpSession session){
        String fullname = null;

        UserDto userDto = (UserDto) session.getAttribute(UserDto.SESSION_USER_KEY);

        if(userDto == null){
            fullname = "匿名";
        }else {
            fullname = userDto.getFullname();
        }

        return fullname + "成功访问了资源m1";
    }


    @RequestMapping("/m2")
    public String m2(HttpSession session){
        String fullname = null;

        UserDto userDto = (UserDto) session.getAttribute(UserDto.SESSION_USER_KEY);

        if(userDto == null){
            fullname = "匿名";
        }else {
            fullname = userDto.getFullname();
        }

        return fullname + "成功访问了资源m2";
    }




}
